/**
 * 测试代码
 *
 * @author bian
 * @createDate 2016.8.27
 */

var common = require("./common");

// auto define common variable
var evalString = "";
Object.keys(common).forEach((e) => {
    evalString += `var ${e} = common.${e};`;
});
if(typeof(evalString) !== "undefined" || evalString !== null){
    eval(evalString);
}

var messageId = new Date().getTime().toString().substr(-4) + parseInt(Math.random() * 1000);
var chatMessage = "<xml><ToUserName>gh_8f38cb88600e</ToUserName>" +
    "<FromUserName>oJ750w76j3SIHc_sGS0ESnBQ7r2o</FromUserName>" +
    "<CreateTime>1472620123</CreateTime>" +
    "<MsgType>text</MsgType>" +
    "<Content>你好的</Content>" +
    "<MsgId>"+ messageId+ "</MsgId></xml>";

var host = "http://127.0.0.1:8866";
describe("it test post data", function () {
    it("test chat data should work ok", function (done) {
        request
            .post(host + "/wechat/wechatCheck")
            .type("xml")
            .send(chatMessage)
            .query({
                timestamp : 124024,
                openid:"oJ750w76j3SIHc_sGS0ESnBQ7r2o",
                signature:"fsdfsfeefe",
                nonce : "123123"
            }).then(function(res) {
                console.log(res.text); 
            });
    });
});


